package com.zhuss.excecise.excecise;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.excecise.excecise.CreateExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.DeleteExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.UpdateExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.CollectExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.DelTopicExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.ForwardExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.RecommendExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.ThumbExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.TopicExceciseBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;

/**
 * excecise操作service（基本操作）
 * @author zhushanshuo
 * @Date 2020-02-05 15:59
 *
 */
@Component("exceciseOperateService")
public class ExceciseOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("exceciseCreate")
	private Processor<Object, CreateExceciseBo> exceciseCreate;
	
	@Autowired
	@Qualifier("exceciseUpdate")
	private Processor<Object, UpdateExceciseBo> exceciseUpdate;
	
	@Autowired
	@Qualifier("exceciseDelete")
	private Processor<Object, DeleteExceciseBo> exceciseDelete;
	
	@Autowired
	@Qualifier("exceciseThumb")
	private Processor<Object, ThumbExceciseBo> exceciseThumb;
	
	@Autowired
	@Qualifier("exceciseCollect")
	private Processor<Object, CollectExceciseBo> exceciseCollect;
	
	@Autowired
	@Qualifier("exceciseForward")
	private Processor<Object, ForwardExceciseBo> exceciseForward;
	
	@Autowired
	@Qualifier("exceciseRecommend")
	private Processor<Object, RecommendExceciseBo> exceciseRecommend;
	
	@Autowired
	@Qualifier("exceciseTopic")
	private Processor<Object, TopicExceciseBo> exceciseTopic;
	
	@Autowired
	@Qualifier("exceciseDelThumb")
	private Processor<Object, ThumbExceciseBo> exceciseDelThumb;
	
	@Autowired
	@Qualifier("exceciseDelCollect")
	private Processor<Object, CollectExceciseBo> exceciseDelCollect;
	
	@Autowired
	@Qualifier("exceciseDelForward")
	private Processor<Object, ForwardExceciseBo> exceciseDelForward;
	
	@Autowired
	@Qualifier("exceciseDelTopic")
	private Processor<Object, DelTopicExceciseBo> exceciseDelTopic;
	
	@Autowired
	@Qualifier("exceciseDelRecommend")
	private Processor<Object, RecommendExceciseBo> exceciseDelRecommend;
	
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws WpsException {
		
		CreateExceciseBo bo = (CreateExceciseBo) param;
		
		exceciseCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws WpsException {
    	
		UpdateExceciseBo bo = (UpdateExceciseBo) param;
		
		exceciseUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws WpsException {
		
		DeleteExceciseBo bo = (DeleteExceciseBo) param;
		
		exceciseDelete.process(bo);
		
		return null;
	}
	
	/**
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void thumb(Object param) throws WpsException {
		
		ThumbExceciseBo bo = (ThumbExceciseBo) param;
		
		exceciseThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void collect(Object param) throws WpsException {
		
		CollectExceciseBo bo = (CollectExceciseBo) param;
		
		exceciseCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void forward(Object param) throws WpsException {
		
		ForwardExceciseBo bo = (ForwardExceciseBo) param;
		
		exceciseForward.process(bo);
		
		return null;
	}
	
	/**
	 * 推荐
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void recommend(Object param) throws WpsException {
		
		RecommendExceciseBo bo = (RecommendExceciseBo) param;
		
		exceciseRecommend.process(bo);
		
		return null;
	}
	
	/**
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void topic(Object param) throws WpsException {
		
		TopicExceciseBo bo = (TopicExceciseBo) param;
		
		exceciseTopic.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delThumb(Object param) throws WpsException {
		
		ThumbExceciseBo bo = (ThumbExceciseBo) param;
		
		exceciseDelThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delCollect(Object param) throws WpsException {
		
		CollectExceciseBo bo = (CollectExceciseBo) param;
		
		exceciseDelCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delForward(Object param) throws WpsException {
		
		ForwardExceciseBo bo = (ForwardExceciseBo) param;
		
		exceciseDelForward.process(bo);
		
		return null;
	}
	
	/**
	 * 删
	 * 推荐
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delRecommend(Object param) throws WpsException {
		
		RecommendExceciseBo bo = (RecommendExceciseBo) param;
		
		exceciseDelRecommend.process(bo);
		
		return null;
	}
	
	/**
	 * 删
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delTopic(Object param) throws WpsException {
		
		DelTopicExceciseBo bo = (DelTopicExceciseBo) param;
		
		exceciseDelTopic.process(bo);
		
		return null;
	}
	
}

